home *** CD-ROM | disk | FTP | other *** search
/ Apple WWDC 1996 / WWDC96_1996 (CD).toast / Technology Materials / QuickTime VR / MacOS / QuickDraw™ 3D 1.0.6F4 SDK / Development / 3DMF parser / 1.0 version / MF3DPC / MFTEXTUT.C < prev    next >
Encoding:
C/C++ Source or Header  |  1995-11-07  |  2.2 KB  |  92 lines  |  [TEXT/dosa]

  1. /*==============================================================================
  2.  *
  3.  *    File:        MFTEXTUT.C
  4.  *
  5.  *    Function:    Text utility routines
  6.  *
  7.  *    Version:    Metafile:    Version 1.0 3DMF files
  8.  *                Package:    Release #2 of this code
  9.  *
  10.  *    Author(s):    Rick Wong (RWW), Duet Development Corp.
  11.  *                John Kelly (JRK), Duet Development Corp.
  12.  *
  13.  *    Copyright:    (c) 1995 by Apple Computer, Inc., all rights reserved.
  14.  *
  15.  *    Change History (most recent first):
  16.  *        FB8_JRK    Segmentation
  17.  *        Fabio    Changed file name to 8 characters
  18.  *        F3A_RWW    TOC stuff works.
  19.  *        F2G_RWW    File created.
  20.  *==============================================================================
  21.  */
  22. #include "MFTEXTUT.H"
  23.  
  24. #include <ctype.h>            /* tolower */
  25.  
  26. #include "MFSYSTYP.H"
  27. #include "MFTYPES.H"
  28. #include "MFASSERT.H"
  29. #include "MFMEMORY.H"
  30.  
  31. #if defined(applec) || defined(__MWERKS__) || defined(THINK_C)
  32. #pragma segment __MF3D__
  33. #endif
  34.  
  35. /*==============================================================================
  36.  *    MF3D_CmpStrInsensitive
  37.  *
  38.  *    Case-insensitive comparison of two strings.
  39.  *
  40.  *    Return 0 for a match; nonzero otherwise.
  41.  *==============================================================================
  42.  */
  43. MF3DInt32
  44. MF3D_CmpStrInsensitive(
  45.     const char        *string1,
  46.     const char        *string2)
  47. {
  48.     MF3DInt32        result;
  49.  
  50.     MFASSERT(string1 != NULL && string2 != NULL);
  51.  
  52.     while((result = (tolower(*string1) - tolower(*string2))) == 0 &&
  53.             *string1++ != '\0' && *string2++ != '\0')
  54.     {
  55.     }
  56.  
  57.     return result;
  58. }
  59.  
  60. /*==============================================================================
  61.  *    MF3D_DuplicateCString
  62.  *
  63.  *    Make a copy of a CStringPtr by allocating another pointer of the same size.
  64.  *==============================================================================
  65.  */
  66. MF3DCStringPtr
  67. MF3D_DuplicateCString(
  68.     MF3DConstCStringPtr    inStringPtr)
  69. {
  70.     MF3DCStringPtr        result;
  71.     MF3DUns32            stringLen;
  72.     MF3DCStringPtr        pdst;
  73.     MF3DConstCStringPtr    psrc;
  74.  
  75.     if (inStringPtr == NULL)
  76.         return NULL;
  77.  
  78.     stringLen = CStringLen(inStringPtr);
  79.  
  80.     result = MF3D_Malloc(stringLen + 1);
  81.  
  82.     if (result != NULL)
  83.     {    pdst = result;
  84.         psrc = inStringPtr;
  85.  
  86.         while (*pdst++ = *psrc++)
  87.             ;
  88.     }
  89.  
  90.     return result;
  91. }
  92.